package com.example.houduan.service;

import com.example.houduan.domain.Jy_sb;
import com.example.houduan.domain.Jy_sbExample;
import com.example.houduan.mapper.Jy_sbMapper;
import com.example.houduan.resp.CommonResp;
import com.example.houduan.resp.Respjysb;
import com.example.houduan.utils.CopyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Jydjservice {
    @Autowired
    private Jy_sbMapper jy_sbMapper;
    public CommonResp add(Jy_sb jy_sb)
    {
        CommonResp commonResp=new CommonResp();
        int insert= jy_sbMapper.insert(jy_sb);
        if (insert==0)
        {
            commonResp.setContent(false);
            return commonResp;
        }else{
            commonResp.setContent(true);
            return commonResp;
        }
    }
    public CommonResp jysbz(String uid)
    {
        CommonResp commonResp = new CommonResp();
        Jy_sbExample jy_sbExample=new Jy_sbExample();
        Jy_sbExample.Criteria criteria=jy_sbExample.createCriteria();
        criteria.andUidEqualTo(uid).andDfdataIsNull();
        List<Jy_sb> jySbs =jy_sbMapper.selectByExample(jy_sbExample);
        List<Respjysb> respjysbs= CopyUtil.copyList(jySbs,Respjysb.class);
        commonResp.setContent(respjysbs);
        return commonResp;
    }
    public CommonResp jysbw(String uid)
    {
        CommonResp commonResp = new CommonResp();
        Jy_sbExample jy_sbExample=new Jy_sbExample();
        Jy_sbExample.Criteria criteria=jy_sbExample.createCriteria();
        criteria.andUidEqualTo(uid).andDfdataIsNotNull();
        List<Jy_sb> jySbs =jy_sbMapper.selectByExample(jy_sbExample);
        List<Respjysb> respjysbs= CopyUtil.copyList(jySbs,Respjysb.class);
        commonResp.setContent(respjysbs);
        return commonResp;
    }
}
